package com.changgou.controller;

import com.changgou.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.*;

/**
 * Thymeleaf demo工程控制器
 * 
 * @author gaofeng
 * @date 2025年04月27日 15:25
 */
@Controller
@RequestMapping("/thymeleaf")
public class ThymeleafController {
    @GetMapping("/test")
    public String test(Model model) {
        model.addAttribute("message", "Thymeleaf");

        List<User> users = new ArrayList<>();
        users.add(new User("张三", 20));
        users.add(new User("李四", 40));
        users.add(new User("王五", 60));
        model.addAttribute("users", users);

        Map<String, String> dataMap = new HashMap<>();
        dataMap.put("No", "12");
        dataMap.put("Address", "南京");
        model.addAttribute("dataMap", dataMap);

        model.addAttribute("now", new Date());
        model.addAttribute("age", 17);

        return "demo1";
    }
}
